// pages/cate/cate.js
Page({
  data:{
    cate:[],
    selectCateId:0
  },
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数
    var that = this;
    wx.request({
      url: 'http://shop.heimicms.com/app/cms/cate_list',
      header: {'content-type':'application/json'}, // 设置请求的 header
      success: function(res){
        that.setData({
          cate:res.data.data,
          selectCateId:res.data.data[0].id          
        })
      },
      fail: function(res) {
        // fail
      },
      complete: function(res) {
        // complete
      }
    })
  },
  onReady:function(){
    // 页面渲染完成
  },
  onShow:function(){
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  },
  onUnload:function(){
    // 页面关闭
  },
  clickCate:function(event){
    var id = event.target.id;
    var cate_name = event.target.dataset.cateName;
    console.log("id="+id);
    this.setData({
      selectCateId:id
    });
    wx.navigateTo({
      url: '../cate2/cate2?id='+id+'&cata_name='+cate_name
    });
  }
})